package org.bsuir.filespocket.view;

import org.bsuir.filespocket.service.UserDAO;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UserListController implements Controller {

    private UserDAO userDAO;

    public void setUserDAO(UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse httpServletResponse)
            throws Exception {
        ModelAndView mav = new ModelAndView("userList");
        mav.addObject("usersList", userDAO.getUsers());

        return mav;
    }
}
